﻿using System.Threading.Channels;
using System.Threading.Tasks;

namespace WYJ.Log.LogWriters
{

    /// <summary>
    /// Output To Other —— OTO
    /// 输出到其它 LogWriter。
    /// </summary>
    public sealed class OTOWriter : LinePassage<string>, ILogWriter
    {
        private readonly ILogWriter _logWriter;

        public OTOWriter(ILogWriter logWriter) : base(Channel.CreateUnbounded<string>())
        {
            _logWriter = logWriter;
        }

        protected override Task Next(string msg)
        {
            _logWriter.WriteAsync(msg);
            return Task.CompletedTask;
        }
    }

}
